﻿@using CRM.Admin.Areas.Customer.Controllers
@using CRM.Admin.Contracts.Dto.Sys
@{
    ViewBag.Title = "Index";
}
@section head
{
    <link href="@Url.Content("~/ScriptPlugin/easyui/themes/gray/easyui.css")" rel="stylesheet" />
    <link href="@Url.Content("~/ScriptPlugin/easyui/themes/icon.css")" rel="stylesheet" />
    <script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/jquery.easyui.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/locale/easyui-lang-zh_CN.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/KingsSharp.DataGrid.Filter.js")"></script>
    <script src="@Url.Content("~/ScriptPlugin/WdatePicker/js/WdatePicker.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/picdata.js")"></script>
}
<div id="grid">
    <div id="toolpannel">
        <div class="content-pannel-buttons">
            <a><b class="p-icon-reload">刷新 </b></a>
            <a onclick="$('#grid').datagrid('load')">
                <b class="p-icon-serch">查询</b>
            </a>
        </div>
        <div class="datagrid-filter-pannel" id="filterpannel">
            <table class="content-table-serch">
                <tr>
                    <th>
                        顾客名称
                    </th>
                    <td>
                        <input type="text" name="Name" data-filter="true" />
                        <a class="p-icon-filter p-icon-filter-style" style="display: block; width: 22px;
                            height: 22px; float: left">@Html.GetFilterItem("Name", typeof(string))</a>
                        </td>
                        <th>
                            顾客档案号
                        </th>
                        <td>
                            <input type="text" name="Code" data-filter="true" />
                            <a class="p-icon-filter p-icon-filter-style" style="display: block; width: 22px;
                            height: 22px; float: left">@Html.GetFilterItem("Code", typeof(string))</a>
                        </td>
                        <th>销售系统编码</th>
                        <td>
                            <input type="text" name="SaleSysCode" data-filter="true" />
                            <a class="p-icon-filter p-icon-filter-style" style="display: block; width: 22px;
                            height: 22px; float: left">@Html.GetFilterItem("SaleSysCode", typeof(string))</a>
                        </td>
                        <th>
                            顾客类别
                        </th>
                        <td>
                            <select id="Type" name="Type" data-filter="true">
                                <option></option>
                                @{
                                    List<DictionaryDto> lbdtos = (List<DictionaryDto>)ViewData[CustomerInfoController.DicCatalogType.KHLB];
                                    foreach (var dto in lbdtos)
                                    {
                                        <option value="@dto.Name">@dto.Name</option>
                                    }
                                }
                            </select>
                            <a class="p-icon-filter p-icon-filter-style" style="display: block; float: left; height: 22px; width: 22px;">
                                @Html.GetFilterItem("Type", typeof(bool))
                            </a>
                        </td>
                    </tr>
                    <tr id="datapicke">
                        <th>
                            注册省
                        </th>
                        <td>
                            <select data-picke="1" id="CustomerAddress.ProvinceCode" name="CustomerAddress.ProvinceCode" data-filter="true"></select>
                            <a class="p-icon-filter p-icon-filter-style" style="display: block; float: left; height: 22px; width: 22px;">
                                @Html.GetFilterItem("CustomerAddress.ProvinceCode", typeof(bool))
                            </a>
                        </td>
                        <th>
                            注册市
                        </th>
                        <td>
                            <select data-picke="2" id="CustomerAddress.CityCode" name="CustomerAddress.CityCode" data-filter="true"></select>
                            <a class="p-icon-filter p-icon-filter-style" style="display: block; float: left; height: 22px; width: 22px;">
                                @Html.GetFilterItem("CustomerAddress.CityCode", typeof(bool))
                            </a>
                        </td>
                        <th>
                            注册区
                        </th>
                        <td>
                            <select data-picke="3" id="CustomerAddress.BoroughCode" name="CustomerAddress.BoroughCode" data-filter="true"></select>
                            <a class="p-icon-filter p-icon-filter-style" style="display: block; float: left; height: 22px; width: 22px;">
                                @Html.GetFilterItem("CustomerAddress.BoroughCode", typeof(bool))
                            </a>
                        </td>
                        <th>
                            所属行业
                        </th>
                        <td>
                            <select id="Industry" name="Industry" data-valid="required" data-filter="true">
                                <option></option>
                                @{

                                    lbdtos = (List<DictionaryDto>)ViewData[CustomerInfoController.DicCatalogType.KHHY];
                                    foreach (var dto in lbdtos)
                                    {
                                        <option value="@dto.Name">@dto.Name</option>
                                    }
                                }
                            </select>
                            <a class="p-icon-filter p-icon-filter-style" style="display: block; float: left; height: 22px; width: 22px;">
                                @Html.GetFilterItem("Industry", typeof(bool))
                            </a>
                        </td>

                    </tr>
                    <tr>

                        <th>
                            主营业务
                        </th>
                        <td>
                            <input type="text" maxlength="20" id="Business" name="Business" data-filter="true" />
                            <a class="p-icon-filter p-icon-filter-style" style="display: block; float: left; height: 22px; width: 22px;">
                                @Html.GetFilterItem("Business", typeof(string))
                            </a>
                        </td>
                        <th>
                            法人代表
                        </th>
                        <td>
                            <input type="text" name="LegalMan" data-filter="true" />
                            <a class="p-icon-filter p-icon-filter-style" style="display: block; width: 22px;
                            height: 22px; float: left">@Html.GetFilterItem("LegalMan", typeof(string))</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    @section foot{
        <script type="text/javascript">
            function LoadCustmerInfoData() {
                var columns = [[
                                { field: "ck", checkbox: true },
                                { field: "Name", title: "顾客名称", width: 170 },
                                { field: "ShortName", title: "顾客简称", width: 100 },
                                { field: "Code", title: "顾客档案号", width: 90 },
                                { field: "SaleSysCode", title: "销售系统编码", width: 90 },
                                { field: "Province", title: "注册省", width: 100 },
                                { field: "City", title: "注册市", width: 100 },
                                { field: "Borough", title: "注册地区", width: 100 },
                                { field: "Description", title: "注册详细地址", width: 190 },
                                { field: "Scale", title: "企业规模/年经营额", width: 100 },
                                { field: "Business", title: "主营业务", width: 90 },
                                { field: "Industry", title: "所属行业", width: 170 },
                                { field: "CreditInfo", title: "资信情况", width: 100 },
                                { field: "TicketBank", title: "开户银行", width: 100 },
                                { field: "TicketBankAccount", title: "开户账号", width: 100 },
                                //{ field: "Profiles", title: "顾客简介", width: 200 },
                                { field: "CreditRatings", title: "顾客信用评价", width: 100 },
                                { field: "AgreementFilishProfiles", title: "顾客年度协议完成情况", width: 200 },
                                { field: "CooperationState", title: "与我公司合作状态", width: 100 },
                                { field: "ParentName", title: "关联顾客名称", width: 100 }
                ]];
                var parameter = {
                    title: "@Html.GetGridTitle("系统管理","顾客信息管理")",
                    columns: columns,
                    url: "@Url.Content("~/Customer/CustomerInfo/GetCustmerInfoGridData")",
                    pageNumber: 1
                };
                var grid = K.GetGridData("#grid", parameter).Grid;
            }
            LoadCustmerInfoData();

            function CustmerInfoAdd() {
                K.layer.iframe({
                    title: "@Html.GetLayerTitle(LayerIcon.Add,"新增顾客")",
                    content: "@Url.Content("~/Customer/CustomerInfo/CustomerInfoAdd")",
                    maxmin: true,
                    initfull: true,
                    btn: ["保存", "返回"],
                    callback: function (result) {
                        if (K.ShowOrAlert(result)) {
                            $("#grid").datagrid("load");
                        }
                    }
                });
            }
            function CustmerInfoEdit(userid) {
                var row = $("#grid").datagrid("getSelected");
                if (row == null) {
                    K.Alert("请选择需编辑的行");
                    return false;
                }
                K.layer.iframe({
                    title: "@Html.GetLayerTitle(LayerIcon.Edit,"编辑顾客")",
                    content: "@Url.Content("~/Customer/CustomerInfo/CustomerInfoEdit")?CustomerId=" + row.Id,
                    maxmin: true,
                    initfull: true,
                    btn: ["保存", "返回"],
                    callback: function (result) {
                        if (K.ShowOrAlert(result)) {
                            $("#grid").datagrid("load");
                        }
                    }
                });
            }
            function CustmerInfoDelete() {
                var row = $("#grid").datagrid("getSelected");
                if (row == null) {
                    K.Alert("请选择需删除的顾客");
                    return false;
                }
                K.Confirm("确认删除顾客 \"" + row.Name + "\" ？", function () {
                    K.AjaxJson("@Url.Content("~/Customer/CustomerInfo/CustomerInfoDelete")", { UserId: row.Id, UserName: row.Name }, function (result) {
                        if (K.ShowOrAlert(result)) {
                            $("#grid").datagrid("load");
                        }
                    }, "顾客 \"" + row.Name + "\"删除中...");
                });
            }
            K.PickeInit("datapicke");
        </script>

    }